import Vue from 'vue'
import VueRouter from 'vue-router'

import Home from '../views/home/Home.vue'
import Login from '../views/login/Login.vue';
import Register from '../views/register/Register.vue';

const StudentsAdd = () => import('../views/home/students/StudentAdd.vue');
const StudentsList = () => import('../views/home/students/StudentsList.vue');
const StudentUpdate = () => import('../views/home/students/StudentUpdate.vue');
const ClassAdd = () => import('../views/home/classes/ClassAdd.vue');
const ClassesList = () => import('../views/home/classes/ClassesList.vue');
const SubjectsList = () => import('../views/home/subjects/SubjectsList.vue');
const CoursesList = () => import('../views/home/courses/CoursesList.vue');
const CourseAdd = () => import('../views/home/courses/CourseAdd.vue');

Vue.use(VueRouter)

const routes = [
	// 路由重定向
	{
		path: '/',
		redirect: '/login'
	},
	{
		path: '/home',
		name: 'Home',
		component: Home,
		children: [
			// 新增学生
			{
				path: 'studentAdd',
				name: 'StudentAdd',
				component: StudentsAdd,
			},
			// 学生列表
			{
				path: 'studentsList',
				name: 'StudentsList',
				component: StudentsList,
			},
			// 修改学生
			// 动态路由
			{
				path: 'studentUpdate/:_id',
				name: 'StudentUpdate',
				component: StudentUpdate,
			},
			// 新增班级
			{
				path: 'classAdd',
				name: 'ClassAdd',
				component: ClassAdd,
			},
			// 班级列表
			{
				path: 'classesList',
				name: 'ClassesList',
				component: ClassesList,
			},
			//专业列表，新增专业包含在该组件中
			{
				path: 'subjectsList',
				name: 'SubjectsList',
				component: SubjectsList,
			},
			//课程列表
			{
				path: 'coursesList',
				name: 'CoursesList',
				component: CoursesList,
			},
			//新增课程
			{
				path: 'courseAdd',
				name: 'CourseAdd',
				component: CourseAdd,
			}
		],
	},
	{
		path: '/login',
		name: 'Login',
		component: Login
	},
	{
		path: '/register',
		name: 'Register',
		component: Register
	},
]

const router = new VueRouter({
	routes
})

export default router